#!/usr/bin/env tclsh

#读取文件 file.txt
set fp [open file.txt r] 
while {[gets $fp line] != -1 } {
    #去掉空首尾格，tab等字符
    set line [string trim $line] 
    scan $line "%f,%d,%d" a b c
    puts "a=$a,b=$b,c=$c"
}
close $fp 

#写文件 生成三角函数 sin.txt 的存储器格式采样文件
set fp [open sin.txt w+]
set PI [expr acos(-1)]
set q 64
set v [list]
for { set i 0 } {$i<$q} {incr i 1} {
    set x [expr $PI/2/($q-1)*$i]
    set dis [format "%5f %5f" [expr sin($x)] [expr cos($x)] ]
    puts $fp $dis
}

close $fp 



